<?php

include_once(dirname(__FILE__) . "../../_DATABASE_DAO/LookupsDAO.class.php");
$lookupDao = new LookupsDAO();
if ($_REQUEST['action'] == 'view') {
    $lookups = $lookupDao->listAll($_REQUEST['module']);
    include('views/lookups/home.php');
    exit;
}
if ($_REQUEST['action'] == 'save') {
    $id="";
    if (isset($_REQUEST['id'])) {
        $id = $_REQUEST['id'];
        $lookup = $lookupDao->edit($_REQUEST['module'], $_REQUEST['name'], $id);
    } else {
        $id= $lookupDao->save($_REQUEST['module'], $_REQUEST['name']);
    }
    
    $lookups = $lookupDao->listAll($_REQUEST['module']);
    include('views/lookups/home.php');
    exit;
}
if ($_REQUEST['action'] == 'create') {
    if(isset($_REQUEST['id']))
    $lookup = $lookupDao->get($_REQUEST['module'],$_REQUEST['id']);
    include ("views/lookups/form.php");
    exit;
}

if($_REQUEST['action'] == 'delete'){
    if(isset($_REQUEST['id']))
        $lookupDao->Delete ($_REQUEST['module'],($_REQUEST['delState']+1)%2,$_REQUEST['id']);
    $lookups = $lookupDao->listAll($_REQUEST['module']);
    include('views/lookups/home.php');
    exit;
}
?>
